/* 组织-基础设置api */

import { ajaxService } from '@/utils/request';

const env = import.meta.env;
// const baseURL = env.VITE_APP_BASE_URL;
const baseURL = env.VITE_DEV_BASE_URL;
// const baseURL2 = env.VITE_DEV_BASE_URL// const baseURL = 'http://192.168.31.129:39001';

// 获取职位管理列表
export function GetPositionList(params: any) {
  return ajaxService({
    url: '/organization/position/set/positionManage',
    method: 'get',
    baseURL,
    params
  });
}

// 根据组织id获取职位管理列表
export function GetPositionListByOrganizationId(params: { id: number }) {
  return ajaxService({
    url: 'hr/organization/position_management/job_management/job/list/id',
    method: 'get',
    baseURL,
    params
  });
}
// 新增职位管理列表
export function PostPositionList(data: any) {
  return ajaxService({
    url: '/organization/position/set/positionManage',
    method: 'post',
    baseURL,
    data
  });
}
// 校验新增职位时是否有重复的职位编码
export function CheckPositionList(params: any) {
  return ajaxService({
    url: '/hr/organization/position_management/job_management/job/list/repeat',
    method: 'get',
    baseURL,
    params
  });
}

// 修改职位管理列表
export function PutPositionList(data: any) {
  return ajaxService({
    url: '/organization/position/set/positionManage',
    method: 'put',
    baseURL,
    data
  });
}

// 修改职位管理列表状态
export function PutPositionListState(data: any) {
  return ajaxService({
    url: '/organization/position/set/positionManage',
    method: 'put',
    baseURL,
    data
  });
}
// 删除职位管理列表
export function DelPositionList(params: any) {
  return ajaxService({
    url: '/organization/position/set/positionManage',
    method: 'delete',
    baseURL,
    params
  });
}

// 获取职务管理
export function GetJobList(params: any) {
  return ajaxService({
    url: '/hr/organization/position_management/position_management/position/list',
    method: 'get',
    baseURL,
    params
  });
}

// 新增修改职务查重
export function CheckJobList(params: any) {
  return ajaxService({
    url: '/hr/organization/position_management/position_management/position/repeat',
    method: 'get',
    baseURL,
    params
  });
}

// 新增职务管理
export function PostJobList(data: any) {
  return ajaxService({
    url: '/hr/organization/position_management/position_management/position/add',
    method: 'post',
    baseURL,
    data
  });
}

// 编辑职务管理
export function PutJobList(data: any) {
  return ajaxService({
    url: '/hr/organization/position_management/position_management/position/update',
    method: 'put',
    baseURL,
    data
  });
}

// 删除职务管理
export function DelJobList(data: any) {
  return ajaxService({
    url: '/hr/organization/position_management/position_management/position/delete',
    method: 'delete',
    baseURL,
    data
  });
}

// 获取标准职位库
export function GetPositionStandard(params: any) {
  return ajaxService({
    url: '/hr/organization/position_management/position_library/position/list',
    method: 'get',
    baseURL,
    params
  });
}

// 获取标准职位库详情
export function GetPositionStandardDetail(params: any) {
  return ajaxService({
    url: '/hr/organization/position_management/position_library/position/detail',
    method: 'get',
    baseURL,
    params
  });
}

// 校验创建标准职位库
export function CheckPositionStandard(params: any) {
  return ajaxService({
    url: '/hr/organization/position_management/position_library/position/repeat',
    method: 'get',
    baseURL,
    params
  });
}

// 删除标准职位库
export function DelPositionStandard(data: { ids: number[] }) {
  return ajaxService({
    url: '/hr/organization/position_management/position_library/position/delete',
    method: 'delete',
    baseURL,
    data
  });
}

// 新增标准职位库
export function PostPositionStandard(data: any) {
  return ajaxService({
    url: '/hr/organization/position_management/position_library/position/add',
    method: 'post',
    baseURL,
    isLoading: true,
    data
  });
}

// 查找标准职位库默认模板
export function GetPositionStandardDefault(params: any) {
  return ajaxService({
    url: '/hr/organization/position_management/position_library/position/template',
    method: 'get',
    baseURL,
    params
  });
}

// 修改标准职位详情
export function PutPositionDetail(data: any) {
  return ajaxService(
    {
      url: '/hr/organization/position_management/position_library/position/update',
      method: 'put',
      baseURL,
      data
    },
    {
      message: '修改成功',
      mode: 'success'
    }
  );
}

// 修改标准职位状态
export function PutPositionStatus(data: any) {
  return ajaxService({
    url: '/hr/organization/position_management/position_library/position/enable',
    method: 'put',
    baseURL,
    data
  });
}

// 导入标准职位列表
export async function ImportPositionStandList(data: any) {
  return ajaxService({
    url: '/excel/standard/import',
    method: 'post',
    baseURL: baseURL,
    headers: {
      'Content-Type': 'multipart/form-data;charset=UTF-8'
    },
    // responseType: 'blob',
    data
  });
}

// 导出标准职位列表
export async function ExportPositionStandList(data: any) {
  return ajaxService({
    url: '/excel/standard/export',
    method: 'post',
    baseURL: baseURL,
    headers: {
      'Content-Type': 'multipart/form-data;charset=UTF-8'
    },
    responseType: 'blob',
    data
  });
}

// 获取职位表头
export function GetPositionSetting(params: any) {
  return ajaxService({
    url: '/organization/position/header/config',
    method: 'get',
    baseURL,
    params
  });
}

// 修改职位表头
export function PutPositionSetting(data: any) {
  return ajaxService({
    url: '/organization/position/header/config',
    method: 'put',
    baseURL,
    data
  });
}

// 新增职位表头
export function PostPositionSetting(data: any) {
  return ajaxService({
    url: '/organization/position/header/config',
    method: 'post',
    baseURL,
    data
  });
}

// 创建使用模板接口
export function PostPositionMerge(data: any) {
  return ajaxService({
    url: '/hr/organization/template/use',
    method: 'post',
    baseURL,
    data
  });
}

// 新增职位管理
export function PostPosition(data: any) {
  return ajaxService(
    {
      url: '/hr/organization/position_management/job_management/job/list',
      method: 'post',
      baseURL,
      isLoading: true,
      data
    },
    {
      message: '新增成功',
      mode: 'success'
    }
  );
}

// 修改职位管理
export function PutPosition(data: any) {
  return ajaxService(
    {
      url: '/hr/organization/position_management/job_management/job/list',
      method: 'put',
      baseURL,
      data
    },
    {
      message: '修改成功',
      mode: 'success'
    }
  );
}

// 修改职位控编
export function PutPositionControlEditing(data: any) {
  return ajaxService({
    url: '/hr/organization/position_management/job_management/job/control',
    method: 'put',
    baseURL,
    data
  });
}

// 修改职位管理启用状态
export function ChangePositionState(data: { ids: any; enable: number }) {
  return ajaxService({
    url: '/hr/organization/position_management/job_management/job/list/enable',
    method: 'put',
    baseURL,
    data
  });
}

// 获取职位管理详情
export function GetPositionDefault(params: any) {
  return ajaxService({
    url: '/hr/organization/position_management/job_management/job/list/detail',
    method: 'get',
    baseURL,
    params
  });
}

/**
 *
 * @param params 获取职位管理列表
 * @returns
 */
export function GetPosition(params: any) {
  return ajaxService({
    url: '/hr/organization/position_management/job_management/job/list',
    method: 'get',
    baseURL,
    params
  });
}

// 导出职位管理列表
export async function ExportPositionList(data: any) {
  return ajaxService({
    url: '/excel/positon/export',
    method: 'post',
    baseURL: baseURL,
    headers: {
      'Content-Type': 'multipart/form-data;charset=UTF-8'
    },
    responseType: 'blob',
    data
  });
}

// 导入标准职位列表
export async function ImportPositionList(data: any) {
  return ajaxService({
    url: '/excel/positon/import',
    method: 'post',
    baseURL: baseURL,
    headers: {
      'Content-Type': 'multipart/form-data;charset=UTF-8'
    },
    // responseType: 'blob',
    data
  });
}

// 删除职位管理
export function DelPosition(data: any) {
  return ajaxService({
    url: '/hr/organization/position_management/job_management/job/list',
    method: 'delete',
    baseURL,
    data
  });
}

// 修改职位管理状态
export function PutPositionState(data: any) {
  return ajaxService({
    url: '/organization/position/set/positionManageStatus',
    method: 'put',
    baseURL,
    data
  });
}

// 获取在职人员
export function GetPositionOnJob(params: any) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/personnel/position',
    method: 'get',
    baseURL,
    params
  });
}

// 根据部门id查找部门下面的职位
export function GetPositionListByDepartmentId(params: { id: number }) {
  return ajaxService({
    url: '/hr/organization/position_management/job_management/job/list/id',
    method: 'get',
    baseURL,
    params
  });
}
